{% extends "WebMainSiteBundle:Course:layout.html.twig" %}
{% set title = "课时管理" %}
{% block title %}
    {{ title }}
{% endblock %}
{% block myJs %}
    <script type="text/javascript" charset="utf-8" src="{{ asset("/public/UE/ueditor.config.js") }}"></script>
    <script type="text/javascript" charset="utf-8" src="{{ asset("/public/UE/ueditor.all.min.js") }}"> </script>
    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
    <script type="text/javascript" charset="utf-8" src="{{ asset("/public/UE/lang/zh-cn/zh-cn.js") }}"></script>
    <script>
        $(function () {
            UE.getEditor('content');
            UE.getEditor('content_new');
            $("#type").change(function () {
                var val = $(this).val();
                var content = $("#type" + val).html();
                $("#content_box").html(content);
            });
        });
    </script>
{% endblock%}

{% block user_main %}

    <form class="form-horizontal" method="post" enctype="multipart/form-data">
        {% if app.request.get("id")  and entity.id is defined %}
            <input type="hidden" name="id" value="{{ app.request.get("id") }}" />
        {% endif %}
        <div class="row">
                <div class="form-group">
                    <div class="col-md-3 text-right"><label class="control-label" for="arrangeId">课时章节:</label></div>
                    <div class="col-md-6">
                        <select name="arrangeId"  class="form-control input-lg">
                            <option value="0">根目录</option>
                            {% for c in courseLessonArranges %}
                                <option {% if entity.arrangeId is defined and entity.arrangeId == c.id %}selected="selected" {% endif %} value="{{ c.id }}">{{ c.name }}</option>
                            {% endfor %}
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-3 text-right"><label class="control-label" for="title">课时标题:</label></div>
                    <div class="col-md-6">
                        <input
                                name="title"
                                id="title"
                                type="text"
                                class="form-control input-lg"
                                placeholder="请设置课时标题"
                                value="{% if entity.title is defined %}{{ entity.title }}{% endif %}"
                                />
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-3 text-right"><label class="control-label" for="orders">课时顺序:</label></div>
                    <div class="col-md-6">
                        <input
                                name="orders"
                                id="orders"
                                type="text"
                                class="form-control input-lg"
                                placeholder="请设置课时顺序"
                                value="{% if entity.orders is defined %}{{ entity.orders }}{% endif %}"
                                />
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-3 text-right"><label class="control-label" for="info">课时简介:</label></div>
                    <div class="col-md-6">
                        <textarea  name="info" class="form-control" rows="11" id="info" placeholder="课时简介">{% if entity.info is defined %}{{ entity.info }}{% endif %}</textarea>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-3 text-right"><label class="control-label" for="type">课时类型:</label></div>
                    <div class="col-md-6">
                        <select id="type" name="type"  class="form-control input-lg">
                            <option {% if entity.type is defined and entity.type == 0 %}selected="selected" {% endif %}  value="0">图文</option>
                            <option {% if entity.type is defined and entity.type == 1 %}selected="selected" {% endif %}  value="1">视频</option>
                            <option {% if entity.type is defined and entity.type == 2 %}selected="selected" {% endif %}  value="2">音频</option>
                            {#<option value="3">直播</option>#}
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-3 text-right"><label class="control-label" for="content">课时内容:</label></div>
                    <div class="col-md-9" id="content_box">
                        {% if entity.type is defined and entity.type == 0 %}
                            <textarea  name="content"  id="content_new" placeholder="课时图文内容">{% if entity.content is defined and entity.type is defined  and entity.type == 0 %}{{ entity.content }}{% endif %}</textarea>
                        {% endif %}
                        {% if entity.type is defined and entity.type == 1 %}
                            <input name="content" type="text" class="form-control input-lg" placeholder="请设置视频地址" value="{% if entity.content is defined and entity.type is defined  and entity.type == 1 %}{{ entity.content }}{% endif %}"/>
                        {% endif %}
                        {% if entity.type is defined and entity.type == 2 %}
                            <input name="content" type="text" class="form-control input-lg" placeholder="请设置音频地址" value="{% if entity.content is defined and entity.type is defined  and entity.type == 2 %}{{ entity.content }}{% endif %}"/>
                        {% endif %}
                        {#<textarea  name="content"  id="content" placeholder="课时内容">{% if entity.content is defined %}{{ entity.content }}{% endif %}</textarea>#}
                    </div>
                </div>
                <p class="buttons-margin-horizontal">
                    <input type="submit" class="btn btn-theme btn-green" value="提交" />
                </p>
        </div>
    </form>
    <div id="type0" style="display: none;">
        <textarea  name="content"  id="content_new" placeholder="课时图文内容">{% if entity.content is defined and entity.type is defined  and entity.type == 0 %}{{ entity.content }}{% endif %}</textarea>
    </div>
    <div id="type1" style="display: none;">
        <input name="content" type="text" class="form-control input-lg" placeholder="请设置视频地址" value="{% if entity.content is defined and entity.type is defined  and entity.type == 1 %}{{ entity.content }}{% endif %}"/>
    </div>
    <div id="type2" style="display: none;">
        <input name="content" type="text" class="form-control input-lg" placeholder="请设置音频地址" value="{% if entity.content is defined and entity.type is defined  and entity.type == 2 %}{{ entity.content }}{% endif %}"/>
    </div>

{% endblock %}